package com.my;

import com.spring.mybatis.MyBeanDefinitionRegistrar;
import com.spring.mybatis.MyScan;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/6/16 13:45
 */
@ComponentScan("com.my")
@MyScan("com.my.mapper")
public class AppConfig {
    
    @Bean
    public SqlSessionFactory sqlSessionFactory() throws IOException {
        InputStream is = Resources.getResourceAsStream("mybatis.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
        return sqlSessionFactory;
    }
    
}
